#ifndef CLIENTCONSOLE_H
#define CLIENTCONSOLE_H

#include "../core/Core.h"
#include "NetConsole.h"

#include <string>

class NetConsole;
class SDL_Thread;
class SDL_mutex;
struct _TCPsocket;
typedef struct _TCPsocket* TCPsocket;

class ClientConsole : Console 
{
private:
	static const int BUFFER_SIZE;
	static const std::string END_LINE;
	
	NetConsole *_parent;
	std::string _name;
	bool _isRunning;
	
	SDL_mutex *_sendLock;
	SDL_mutex *_recvLock;
	
	TCPsocket _sock;
	SDL_Thread *_clientThread;
	std::vector<std::string> _outMessages;
	
	static int clientMain(void *owner);
	bool handleMessage(std::string& message);
public:
	ClientConsole(NetConsole *parent, TCPsocket sock, std::string name);
	~ClientConsole();

	void close();
	void sendMessage(const std::string& message);
	std::vector<std::string> receiveMessages();
};

#endif